import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '@/views/common/layout'

import Login from '@/views/login/index'
import Register from '@/views/register/index'

// 二级路由
import Home from '@/views/home/index'
import Cart from '@/views/cart/index'
import Order from '@/views/order/index'
import User from '@/views/user/index'

// 跳转路由
import DishDetail from '@/views/home/detail/DishDetail'
import SetmealDetail from '@/views/home/detail/SetmealDetail'
import SearchList from '@/views/search/index'
import AddressBook from '@/views/address/index'
import AddAddress from '@/views/address/addOrEdit/add'
import EditAddress from '@/views/address/addOrEdit/edit'
import UserInfo from '@/views/user/userInfo/index'
import PayIndex from '@/views/pay/index'
import PaySuccess from '@/views/pay/paySuccess/index'
import OrderDetail from '@/views/order/OrderDetail/index'

Vue.use(VueRouter)

const routes = [
  { name: 'Login', path: '/login', component: Login },
  { name: 'Register', path: '/register', component: Register },
  {
    path: '/',
    component: layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: Home
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/user',
        component: User
      }
    ]
  },
  // 点击跳转到菜品详情界面
  { name: 'DishDetail', path: '/dishDetail', component: DishDetail },
  // 点击跳转到套餐详情界面
  { name: 'SetmealDetail', path: '/setmealDetail', component: SetmealDetail },
  // 点击首页搜索框跳转到搜索界面
  { name: 'SearchList', path: '/searchList', component: SearchList },
  // 点击收获地址跳转到地址簿
  { name: 'AddressBook', path: '/addressBook', component: AddressBook },
  { name: 'AddAddress', path: '/addAddress', component: AddAddress },
  { name: 'EditAddress', path: '/editAddress', component: EditAddress },
  { name: 'UserInfo', path: '/userInfo', component: UserInfo },
  { name: 'PayIndex', path: '/pay', component: PayIndex },
  { name: 'PaySuccess', path: '/paySuccess', component: PaySuccess },
  {
    path: '/order',
    component: Order
  },
  { name: 'OrderDetail', path: '/orderDetail', component: OrderDetail }
]

const router = new VueRouter({
  routes
})

export default router
